<template>
  <div>
    <video
      v-if="videoSrc[returnVideoSrc()]"
      id="video-background"
      preload="auto"
      autoplay
      muted
      :src="videoSrc[returnVideoSrc()]"></video>
    <NavBar></NavBar>
    <router-view />
  </div>
</template>

<script>
import NavBar from "@/components/NavBar.vue";
import "bootstrap/dist/css/bootstrap.min.css";
import "bootstrap/dist/js/bootstrap";
import { useStore } from "vuex";

export default {
  components: {
    NavBar,
  },

  setup() {
    const videoSrc = [
      "https://king-of-bots.oss-cn-beijing.aliyuncs.com/video/%E5%BC%80%E5%A7%8B%E5%8C%B9%E9%85%8D%E5%8A%A8%E7%94%BB.mp4",
      "https://king-of-bots.oss-cn-beijing.aliyuncs.com/video/%E5%8F%96%E6%B6%88%E5%8C%B9%E9%85%8D%E5%8A%A8%E7%94%BB.mp4",
    ];

    const store = useStore();
    // 方法:返回选中哪个视频作为背景
    function returnVideoSrc() {
      if (store.state.pk.status === "model" || store.state.pk.status === "matching") return 1;
      else return 0;
    }

    return {
      videoSrc,
      returnVideoSrc,
    };
  },
};
</script>

<style>
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#video-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
}

#video-background.fade-out {
  opacity: 0;
}
</style>
